﻿
@{
    ViewData["Title"] = "考成成绩";
    Layout = "~/Views/Shared/_LayoutHUI.cshtml";
}

<header class="hui-header">

    @*<div id="hui-back"></div>*@

    <h1>考成成绩</h1>
</header>



<div class="hui-wrap" style="text-align: center; width: 100%;">
    <br />
    <br />
    <br />
    <br />
    <div class="line"></div>
    <h1 style="font-size:large" id="username">
    </h1>
    <h1 style="font-size:large">本次考试成绩为：</h1>
    <h3 style="font-size:large">@ViewBag.fen 分 </h3>
    <input type="hidden" id="cid" value="@ViewBag.cid" />
    <input type="hidden" id="fen" value="@ViewBag.fen" />
    @if ((double)ViewBag.fen <= 60)
    {
        <img src="~/images/icon/未通过.png" />

    }
    else
    {
        <img id="zjimg" width="95%" />
        <button type="button" onclick="upLoad('考试证书.JPG')" class="hui-button hui-button-large hui-primary" style="margin-top:15px;">下载证书</button>
    }
</div>
@section Scripts{
    <script>
        var username = localStorage.getItem("username");
        var unitwork = localStorage.getItem("unitwork");
        $('#username').text(username);
        src_value = '/AvoidTheLoginTest/Certificate?id=' + $('#cid').val() + '&&username=' + username + '&&unitwork=' + unitwork + '&&fen=' + $('#fen').val();
        $("#zjimg").attr("src", src_value);
        function upLoad(imgName) {
            var username = localStorage.getItem("username");
            var unitwork = localStorage.getItem("unitwork");
            var _OBJECT_URL;
            var request = new XMLHttpRequest();
            request.addEventListener('readystatechange', function (e) {
                if (request.readyState == 4) {
                    _OBJECT_URL = URL.createObjectURL(request.response);
                    var $a = $("<a></a>").attr("href", _OBJECT_URL).attr("download", imgName);
                    $a[0].click();
                }
            });
            request.responseType = 'blob';
            request.open('get', '/AvoidTheLoginTest/Certificate?id=' + $('#cid').val() + '&&username=' + username + '&&unitwork=' + unitwork + '&&fen=' + $('#fen').val());
            request.send();
        }

    </script>
}